package core.report.yearReport.bean;

import org.springframework.jdbc.support.rowset.SqlRowSet;

import core.report.yearReport.util.ExportExcelUtil;

public class Networkio extends BaseExcelReportDataBean {
	private String name;

	private int attribute_id;
	private int shopid;
	private String shop_name;
	private long views;
	private double views_per;
	private double guests;
	private double guests_per;
	private double networkio;
	private double networkio_per;
	private double views_rate;
	private double guests_rate;
	private String T_location;
	private String N_location;

	public Networkio() {
	}

	public Networkio(SqlRowSet rs) {
		this.attribute_id = rs.getInt("attribute_id");
		this.shopid = rs.getInt("shopid");
		this.shop_name = rs.getString("shop_name");
		this.views = rs.getLong("views");
		this.guests = rs.getDouble("guests");
		this.views_per = rs.getDouble("views_per");
		this.guests_per = rs.getDouble("guests_per");
		this.networkio = rs.getDouble("networkio");
		this.networkio_per = rs.getDouble("networkio_per");
		this.views_rate = rs.getDouble("views_rate");
		this.guests_rate = rs.getDouble("guests_rate");
		this.T_location = rs.getString("T_location");
		this.N_location = rs.getString("N_location");

		this.name = this.shop_name;
	}

	public void addProperties(Networkio data) {
		this.setViews(this.getViews() + data.getViews());
		this.setGuests(this.getGuests() + data.getGuests());
		this.setViews_per(this.getViews_per() + data.getViews_per());
		this.setGuests_per(this.getGuests_per() + data.getGuests_per());
		this.setNetworkio(this.getNetworkio() + data.getNetworkio());
		this
				.setNetworkio_per(this.getNetworkio_per()
						+ data.getNetworkio_per());
		this.setViews_rate(this.getViews_rate() + data.getViews_rate());
		this.setGuests_rate(this.getGuests_rate() + data.getGuests_rate());

	}

	public void subtract(int size) {
		if (size != 0) {
			this.setViews_per(this.getViews_per()/size);
			this.setGuests_per(this.getGuests_per()/size);
			this.setViews_rate(this.getViews_rate() / size);
			this.setGuests_rate(this.getGuests_rate() / size);
			this.setNetworkio_per(this.getNetworkio_per());
		} else {
			this.setViews_per(0);
			this.setGuests_per(0);
			this.setViews_rate(0);
			this.setGuests_rate(0);
			this.setNetworkio_per(0);
		}
	}

	@Override
	public int getFormatTypeByIndex(int index) {
		switch (index) {
		case 0:
			return ExportExcelUtil.TEXT_TYPE;
		case 1:
			return ExportExcelUtil.LONG_TYPE;
		case 2:
			return ExportExcelUtil.PERCENT_TYPE;
		case 3:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 4:
			return ExportExcelUtil.PERCENT_TYPE;
		case 5:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 6:
			return ExportExcelUtil.PERCENT_TYPE;
		case 7:
			return ExportExcelUtil.PERCENT_TYPE;
		case 8:
			return ExportExcelUtil.PERCENT_TYPE;
		case 9:
			return ExportExcelUtil.TEXT_TYPE;
		case 10:
			return ExportExcelUtil.TEXT_TYPE;
		default:
			return ExportExcelUtil.TEXT_TYPE;
		}
	}

	@Override
	public String getValueByIndex(int index) {
		String value = "";
		switch (index) {
		case 0:
			value = this.getName();
			break;
		case 1:
			value = this.getViews() + "";
			break;
		case 2:
			value = this.getViews_per() + "";
			break;
		case 3:
			value = this.getGuests() + "";
			break;
		case 4:
			value = this.getGuests_per() + "";
			break;
		case 5:
			value = this.getNetworkio() + "";
			break;
		case 6:
			value = this.getNetworkio_per() + "";
			break;
		case 7:
			value = this.getViews_rate() + "";
			break;
		case 8:
			value = this.getGuests_rate() + "";
			break;
		case 9:
			value = this.getT_location() ;
			break;
		case 10:
			value = this.getN_location() ;
			break;
		}
		return value;
	}

	public int getAttribute_id() {
		return attribute_id;
	}

	public void setAttribute_id(int attribute_id) {
		this.attribute_id = attribute_id;
	}

	public int getShopid() {
		return shopid;
	}

	public void setShopid(int shopid) {
		this.shopid = shopid;
	}

	public String getShop_name() {
		return shop_name;
	}

	public void setShop_name(String shop_name) {
		this.shop_name = shop_name;
	}

	public long getViews() {
		return views;
	}

	public void setViews(long views) {
		this.views = views;
	}

	public double getGuests() {
		return guests;
	}

	public void setGuests(double guests) {
		this.guests = guests;
	}

	public double getViews_per() {
		return views_per;
	}

	public void setViews_per(double views_per) {
		this.views_per = views_per;
	}

	public double getGuests_per() {
		return guests_per;
	}

	public void setGuests_per(double guests_per) {
		this.guests_per = guests_per;
	}

	public double getNetworkio() {
		return networkio;
	}

	public void setNetworkio(double networkio) {
		this.networkio = networkio;
	}

	public double getNetworkio_per() {
		return networkio_per;
	}

	public void setNetworkio_per(double networkio_per) {
		this.networkio_per = networkio_per;
	}

	public double getViews_rate() {
		return views_rate;
	}

	public void setViews_rate(double views_rate) {
		this.views_rate = views_rate;
	}

	public double getGuests_rate() {
		return guests_rate;
	}

	public void setGuests_rate(double guests_rate) {
		this.guests_rate = guests_rate;
	}

	public String getT_location() {
		return T_location;
	}

	public void setT_location(String t_location) {
		T_location = t_location;
	}

	public String getN_location() {
		return N_location;
	}

	public void setN_location(String n_location) {
		N_location = n_location;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
